#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Patch Creator_Icon.ico
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Crypt.au3>
;Recursive File Lister

Dim $FolderName = FileSelectFolder("","")
If $FolderName = "" Then Exit
Dim $FileCount = 0

_Crypt_Startup()
FileDelete("FileList.txt")
$file = FileOpen(@ScriptDir & "\FileList.txt",1)

_ScanFolder($FolderName)

FileClose($file)
_Crypt_Shutdown()

MsgBox(0,"Done","Folder Scan Complete.  Scanned " & $FileCount & " Files")

Func _ScanFolder($SourceFolder)
	Local $Search
	Local $File
	Local $FileAttributes
	Local $FullFilePath

	$Search = FileFindFirstFile($SourceFolder & "\*.*")

	While 1
		If $Search = -1 Then
			ExitLoop
		EndIf

		$File = FileFindNextFile($Search)
		If @error Then ExitLoop

		$FullFilePath = $SourceFolder & "\" & $File
		$FileAttributes = FileGetAttrib($FullFilePath)

		If StringInStr($FileAttributes,"D") Then
			_ScanFolder($FullFilePath)
		Else
			_LogFile($FullFilePath)
		EndIf

	WEnd

	FileClose($Search)
EndFunc

Func _LogFile($FileName)
	FileWriteLine($file,StringReplace($FileName,$FolderName,"")&"|"&_Crypt_HashFile($FileName,$CALG_SHA1))
	$FileCount += 1
	ToolTip($FileName,0,0)
EndFunc
